package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Aspect
public class Myadvice {

    @Pointcut("execution(* com.itheima.Service.BookService.registerBook())")
    public void pt(){}

    @Around("pt()")
    public void around(ProceedingJoinPoint pjp) throws Throwable {

        Object[] args = pjp.getArgs();
        for(int i=0;i<args.length;i++){

            if(args[i].getClass().equals(String.class)){
                args[i] = args[i].toString().trim();
            }
        }
        System.out.println(Arrays.toString(args));
        pjp.proceed(args);
    }
}
